﻿using System.Collections.Generic;
using Missbot.Service;

namespace Missbot.AIModule.Pet.PetAgainst
{
    /// <summary>
    /// 宠物技能
    /// </summary>
    public class PetSkill : DbBaseEntity
    {
        /// <summary>
        /// 技能名
        /// </summary>
        public string Name { get; set; }
        
        /// <summary>
        /// 技能描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 技能数据
        /// </summary>
        public Dictionary<string, int[]> Data { get; set; }

        /// <summary>
        /// 可以学习该技能的等级
        /// </summary>
        public int LearnLevel { get; set; }
    }

    public static class PetSkillDA
    {
        /// <summary>
        /// 通用描述
        /// </summary>
        public static string CommDesc(this PetSkill entity)
        {
            var desc = new string(entity.Description);
            foreach (var (key, values) in entity.Data)
            {
                desc = desc.Replace(key, string.Join("/", values));
            }

            return desc;
        }

        /// <summary>
        /// 获取所有宠物技能
        /// </summary>
        /// <returns></returns>
        public static List<PetSkill> GetAll()
        {
            return MongoService<PetSkill>.Get();
        }
    }
}